<template>
  <!--分润记录-->
  <div class="statistics-container">
    <vab-query-form>
      <vab-query-form-right-panel :span="50">
        <el-form :inline="true" :model="queryForm" @submit.native.prevent>
<!--          <el-form-item>
            <div style="width: 80px">分润合计：</div>
          </el-form-item>-->
<!--          <el-form-item>
            <div style="width: 80px">渠道商：</div>
          </el-form-item>-->
          <el-form-item>
            <el-select
              v-model="queryForm.user"
              clearable
              placeholder="请选择渠道商"
              style="width:180px;"
            > <!--@change="selectType()" -->
              <el-option
                v-for="item in user"
                :key="item.value"
                :label="item.text"
                :value="item.value"
              />
            </el-select>
          </el-form-item>
<!--          <el-form-item>
            <div style="width: 80px">创建时间：</div>
          </el-form-item>-->
          <el-form-item>
            <el-date-picker
              v-model="queryForm.date"
              type="datetimerange"
              value-format="yyyy-M-d H:m:s"
              range-separator="-"
              start-placeholder="开始日期"
              end-placeholder="结束日期"
              style="width:340px;"
            />
          </el-form-item>
          <el-form-item>
            <el-button
              type="primary"
              icon="el-icon-search"
              @click="handleSearch"
            >
              查询
            </el-button>
          </el-form-item>
          <el-form-item>
            <el-button
              type="primary"
              icon="el-icon-refresh-right"
              @click="restart"
            >
              重置
            </el-button>
          </el-form-item>
        </el-form>
      </vab-query-form-right-panel>
    </vab-query-form>

    <el-table
      v-loading="listLoading"
      :data="list"
      @selection-change="setSelectRows"
    >
      <el-table-column
        align="center"
        show-overflow-tooltip
        label="序号"
        sortable
        type="index"
      />
      <el-table-column
        align="center"
        show-overflow-tooltip
        prop="mobile"
        label="平台账号"
      />
      <el-table-column
        align="center"
        show-overflow-tooltip
        prop="company_name"
        label="所属商户"
      />
      <el-table-column
        align="center"
        show-overflow-tooltip
        prop="company_type_text"
        label="商户类型"
      />
      <el-table-column
        align="center"
        show-overflow-tooltip
        prop="supplier_name"
        label="收款人"
      />
      <el-table-column
        align="center"
        show-overflow-tooltip
        prop="create_time"
        label="创建时间"
      />
      <el-table-column
        align="center"
        show-overflow-tooltip
        prop="total_money"
        label="总付款金额"
      />
      <el-table-column
        align="center"
        show-overflow-tooltip
        prop="rate"
        label="费率"
      />
      <el-table-column
        align="center"
        show-overflow-tooltip
        prop="service_total"
        label="应付服务费"
      />
      <el-table-column
        align="center"
        show-overflow-tooltip
        prop="coupon_money"
        label="优惠券折扣"
      />
      <el-table-column
        align="center"
        show-overflow-tooltip
        prop="real_service_total"
        label="实付服务费"
      />
      <el-table-column
        align="center"
        show-overflow-tooltip
        prop="channel_from_text"
        label="渠道商"
      />
      <el-table-column
        align="center"
        show-overflow-tooltip
        prop="proportion_rate"
        label="分润比例"
      />
      <el-table-column
        align="center"
        show-overflow-tooltip
        prop="share"
        label="分润金额"
      />
    </el-table>
    <el-pagination
      background
      :current-page="queryForm.page"
      :page-size="queryForm.list_row"
      :layout="layout"
      :total="total"
      @size-change="handleSizeChange"
      @current-change="handleCurrentChange"
    />
  </div>
</template>

<script>
  import { getChannelShareLists,getChannelShareSearchItemss } from '@/api/common'

  export default {
    name: 'Record',
    data() {
      return {
        user: [],
        queryForm: {
          user: '',
          date: '',
        },
        form: {
          content: '',
        },
        disabled: false,
        listLoading: false,
        list: [],
        layout: 'total, sizes, prev, pager, next, jumper',
        total: 0,
        dialogFormVisible: false,
        dialogFormVisible1: false,
        payimg: '',
      }
    },
    created() {
      this.getData()
      this.getData2()
    },
    methods: {
      handleDetail() {},
      //搜索
      handleSearch() {
        this.getData()
      },
      restart() {
        this.queryForm = []
        this.getData()
      },
      getData2() {
        getChannelShareSearchItemss().then((data)=>{
          this.user = data.data.channelItems
        })
      },
      getData() {
        let params = {
          page: this.queryForm.page,
          limit: this.queryForm.list_row,
          create_time_begin: this.queryForm.date[0],
          create_time_end: this.queryForm.date[1],
          channel_from:this.queryForm.user,
        }
        getChannelShareLists(params).then((data) => {
          this.list = data.data.data
          this.total = data.count
        })

      },
      setSelectRows() {},
      handleSizeChange(val) {
        this.queryForm.list_row = val
        this.getData()
      },
      handleCurrentChange(val) {
        this.queryForm.page = val
        this.getData()
      },
      selectType(e) {
        this.queryForm.types === e.value
      },
    },
  }
</script>

<style lang="scss" scoped>
  .el-button {
    font-size: 14px;
    margin-right: 20px;
  }
</style>
